<!--#Include File="Include.asp"--><%
'--------------------------------------
'Power By 方卡在线 @2010-2014 f02
'URL:http://www.fangka.net/
'EMail:admin@ifangka.com
'QQ:861118936
'版权所有 未经允许不得去除本版权信息
'--------------------------------------

Call CheckAdminType("0,1",UType)

Dim Fk_GBook_Title,Fk_GBook_Content,Fk_GBook_Show,Fk_GBook_Ip,Fk_GBook_Time,Fk_GBook_Re,Fk_GBook_ReAdmin,Fk_GBook_ReTime
Dim Fk_Model_GoUrl,Fk_Model_Succeed,Fk_Model_Repeat,Fk_Model_NoTrash,Fk_Model_TrashPint,Fk_Model_MinStr,Fk_Model_MaxStr
Dim Field_Title,Field_Name,Field_Label,Field_StrMin,Field_StrMax,Field_ListShow
Dim FormStr,ListShowField

MenuId=Clng(Request.QueryString("Menu"))
ModuleId=Clng(Request.QueryString("Module"))
Types=Clng(Request.QueryString("Type"))

If UShowModule="all" Then
	ULimit="all"
End If
Call CheckAdminLimit(ULimit,"v_"&ModuleId,0)

Sqlstr="Select Fk_Module_Name,Fk_Module_GBookReply,Fk_Module_Model,Fk_Module_Url From [Fk_Module] Where Fk_Module_Id=" & ModuleId
Rs.Open Sqlstr,Conn,1,1
If Not Rs.Eof Then
	ModuleName=Rs("Fk_Module_Name")
	ModuleGBookReply=Rs("Fk_Module_GBookReply")
	ModuleUrl=Rs("Fk_Module_Url")
	
	ModelId=Rs("Fk_Module_Model")
Else
	Rs.Close
	Call FKFun.ShowErr("菜单项不存在！",1)
End If
Rs.Close

Sqlstr="Select Fk_Model_ViewName,Fk_Model_Field From [Fk_Model] Where Fk_Model_Id=" & ModelId
Rs.Open Sqlstr,Conn,1,1
If Not Rs.Eof Then
	ModelName="留言"
	ModelField=Rs("Fk_Model_Field")
Else
	Rs.Close
	Call FKFun.ShowErr("模型不存在！",1)
End If
Rs.Close

Fk_Model_GoUrl=FKFun.GetSub(ModelField,"Field_GoUrl:","|;|","")
Fk_Model_Succeed=FKFun.GetSub(ModelField,"Field_Succeed:","|;|","")
Fk_Model_Repeat=FKFun.GetSub(ModelField,"Field_Repeat:","|;|","")
Fk_Model_NoTrash=Clng(FKFun.GetSub(ModelField,"Field_NoTrash:","|;|",""))
Fk_Model_TrashPint=FKFun.GetSub(ModelField,"Field_TrashPint:","|;|","")
Fk_Model_MinStr=FKFun.GetSub(ModelField,"Field_MinStr:","|;|","")
Fk_Model_MaxStr=FKFun.GetSub(ModelField,"Field_MaxStr:","|;||","")
Field_Title=FKFun.GetSub(ModelField,"|GModelOption|Field_Name:","|;|","")

Select Case Types
	Case 1
		Call GBookList() '留言列表
	Case 2
		Call GBookReForm() '回复留言表单
	Case 3
		Call GBookReDo() '执行修改回复
	Case 4
		Call GBookDelDo() '执行删除留言
	Case 5
		Call GBookBatchDelDo() '执行批量删除留言
	Case Else
		Call FKFun.ShowErr("未发现功能项！",1)
End Select

'==========================================
'函 数 名：GBookList()
'作    用：留言列表
'==========================================
Sub GBookList()
	PageNow=Request.QueryString("Page")
	If PageNow<>"" Then
		PageNow=Clng(PageNow)
	Else
		PageNow=1
	End If
	
	Response.Cookies("url_f02")=FKFun.GetNowUrl()
%>
		<div id="rightNav">
			<ul>
				<li><a href="<%=Request.Cookies("url_f02")%>" target='get' div='mainRight'>刷新</a></li>
			</ul>
		</div>
		<div id="searchLine" class="font_bold">
			“<%=ModuleName%>”<%=ModelName%>管理
		</div>
		<form id="TryBatch" name="TryBatch" method="post" target="ajax" action="" showStr="" refreshUrl="<%=Request.Cookies("url_f02")%>" confirmStr="">
		<table width="100%" bordercolor="#CCCCCC" border="1" cellspacing="0" cellpadding="0">
			<tr>
				<th align="center">序号</th>
				<th align="center">选</th>
<%
	ListShowField=""
	TempArr=Split(Split(ModelField,"|GModelOption|")(1),"|FieldList|")
	For Each Temp In TempArr
		If Temp<>"" Then
			Field_Name=FKFun.GetSub(Temp,"Field_Name:","|;|","")
			Field_Label=FKFun.GetSub(Temp,"Field_Label:","|;|","")
			Field_ListShow=FKFun.GetSub(Temp,"Field_ListShow:","|;|","0")
			If Field_ListShow="1" Then
				ListShowField=ListShowField&","&Field_Label
%>
				<th align="center"><%=Field_Name%></th>
<%
			End If
		End If
	Next
%>
				<th align="center">留言IP</th>
				<th align="center">留言时间</th>
				<th align="center">是否显示</th>
				<th align="center">状态</th>
				<th align="center">处理人员</th>
				<th align="center">处理时间</th>
				<th align="center">操作</th>
			</tr>
<%
	Dim Rs2
	Set Rs2=Server.Createobject("Adodb.RecordSet")
	Sqlstr="Select Fk_GBook_Id,Fk_GBook_Title,Fk_GBook_Content,Fk_GBook_Show,Fk_GBook_Ip,Fk_GBook_Time,Fk_GBook_ReAdmin,Fk_GBook_ReIp,Fk_GBook_ReTime From [Fk_GBook] Where Fk_GBook_Module="&ModuleId&" Order By Fk_GBook_Id Desc"
	Rs.Open Sqlstr,Conn,1,1
	If Not Rs.Eof Then
		i=1+(PageNow-1)*PageSizes
		Rs.PageSize=PageSizes
		If PageNow>Rs.PageCount Or PageNow<=0 Then
			PageNow=1
		End If
		PageCounts=Rs.PageCount
		Rs.AbsolutePage=PageNow
		PageRecordCount=Rs.RecordCount
		j=1
		While (Not Rs.Eof) And j<PageSizes+1
			If Rs("Fk_GBook_ReAdmin")>0 Then
				Fk_GBook_Re="已处理"
				Fk_GBook_ReTime=Rs("Fk_GBook_ReTime")
				Sqlstr="Select Fk_Admin_LoginName,Fk_Admin_Name From [Fk_Admin] Where Fk_Admin_Id=" & Rs("Fk_GBook_ReAdmin")
				Rs2.Open Sqlstr,Conn,1,1
				If Not Rs2.Eof Then
					Fk_GBook_ReAdmin=Rs2("Fk_Admin_Name")&"["&Rs2("Fk_Admin_LoginName")&"]"
				Else
					Fk_GBook_ReAdmin="未知"
				End If
				Rs2.Close
			Else
				Fk_GBook_Re="未处理"
				Fk_GBook_ReAdmin="-"
				Fk_GBook_ReTime="-"
			End If
%>
			<tr>
				<td height="24" align="center"><%=i%></td>
				<td align="center"><input type="checkbox" name="ListId" class="input" value="<%=Rs("Fk_GBook_Id")%>" id="List<%=Rs("Fk_GBook_Id")%>" /></td>
<%
			TempArr=Split(ListShowField,",")
			For Each Temp In TempArr
				If Temp<>"" Then
						FormStr=FKFun.GetSub(Rs("Fk_GBook_Content"),Temp&"|:|","|;|","")
%>
				<td align="center"><%=FormStr%></td>
<%
				End If
			Next
%>
				<td align="center"><%=Rs("Fk_GBook_Ip")%></td>
				<td align="center"><%=Rs("Fk_GBook_Time")%></td>
				<td align="center"><%=FKFun.GetShowName(Rs("Fk_GBook_Show"))%></td>
				<td align="center"><%=Fk_GBook_Re%></td>
				<td align="center"><%=Fk_GBook_ReAdmin%></td>
				<td align="center"><%=Fk_GBook_ReTime%></td>
				<td align="center"><a href="GBook.asp?Type=2&Menu=<%=MenuId%>&Module=<%=ModuleId%>&Id=<%=Rs("Fk_GBook_Id")%>" target="dialog" width="770">回复</a> <a href="GBook.asp?Type=4&Menu=<%=MenuId%>&Module=<%=ModuleId%>&Id=<%=Rs("Fk_GBook_Id")%>" target="delete" confirmStr="您确认要删除“<%=Rs("Fk_GBook_Title")%>”？此操作不可逆！" refreshUrl="<%=Request.Cookies("url_f02")%>" showStr="<%=ModelName%>删除成功！">删除</a></td>
			</tr>
<%
			Rs.MoveNext
			i=i+1
			j=j+1
		Wend
	Else
%>
			<tr>
				<td height="25" colspan="20" align="center">暂无记录</td>
			</tr>
<%
	End If
	Rs.Close
%>
			<tr>
				<td height="30" colspan="20">
					&nbsp;&nbsp;<input type="checkbox" name="chkall" class="input" id="chkall" value="select" onclick="CheckAll(this.form)"> 全选
					&nbsp;&nbsp;<input type="submit" value="删 除" class="button" onclick="batchDel();">
					&nbsp;&nbsp;<%Call FKFun.ShowPageCode("GBook.asp?Type=1&Menu="&MenuId&"&Module="&ModuleId&"&Page=",PageNow,PageRecordCount,PageSizes,PageCounts)%>
				</td>
			</tr>
		</table>
		</form>
		<div id="rightBottom">
		
		</div>
<script type="text/javascript">
function batchDel(){
	$('#TryBatch').attr('confirmStr','此操作无法恢复！！！请慎重！！！\n\n确定要删除选中的记录吗？');
	$('#TryBatch').attr('showStr','批量删除成功！');
	$('#TryBatch').attr('action','GBook.asp?Type=5&Menu=<%=MenuId%>&Module=<%=ModuleId%>');
}
</script>
<%
End Sub

'==========================================
'函 数 名：GBookReForm()
'作    用：回复留言表单
'==========================================
Sub GBookReForm()
	Dim TempArr2
	Id=Clng(Request.QueryString("Id"))
	Sqlstr="Select Fk_GBook_Title,Fk_GBook_Content,Fk_GBook_Show,Fk_GBook_Ip,Fk_GBook_Time,Fk_GBook_Re From [Fk_GBook] Where Fk_GBook_Module="&ModuleId&" And Fk_GBook_Id=" & Id
	Rs.Open Sqlstr,Conn,1,1
	If Not Rs.Eof Then
		Fk_GBook_Title=Rs("Fk_GBook_Title")
		Fk_GBook_Content=Rs("Fk_GBook_Content")
		Fk_GBook_Show=Rs("Fk_GBook_Show")
		Fk_GBook_Ip=Rs("Fk_GBook_Ip")
		Fk_GBook_Time=Rs("Fk_GBook_Time")
		Fk_GBook_Re=Rs("Fk_GBook_Re")
	Else
		Rs.Close
		Call FKFun.ShowErr(ModelName&"不存在！",1)
	End If
	Rs.Close
%>
<form id="GBookRe" name="GBookRe" method="post" target="ajax" action="GBook.asp?Type=3&Menu=<%=MenuId%>&Module=<%=ModuleId%>" showStr="<%=ModelName%>处理成功！" refreshUrl="<%=Request.Cookies("url_f02")%>" boxClose="1">
<div id="title">处理<%=ModelName%></div>
<div id="box">
	<table width="90%" border="1" bordercolor="#CCCCCC" align="center" cellpadding="0" cellspacing="0">
<%
	TempArr=Split(Split(ModelField,"|GModelOption|")(1),"|FieldList|")
	For Each Temp In TempArr
		If Temp<>"" Then
			Field_Name=FKFun.GetSub(Temp,"Field_Name:","|;|","")
			Field_Label=FKFun.GetSub(Temp,"Field_Label:","|;|","")
			FormStr=FKFun.GetSub(Fk_GBook_Content,Field_Label&"|:|","|;|","")
%>
		<tr>
			<td width="12%" height="30" align="right"><%=Field_Name%>：</td>
			<td width="88%">&nbsp;<%=FormStr%></td>
		</tr>
<%
		End IF
	Next
%>
        <tr>
            <td height="30" align="right">发布者IP：</td>
            <td>&nbsp;<%=Fk_GBook_Ip%></td>
        </tr>
        <tr>
            <td height="30" align="right">发布时间：</td>
            <td>&nbsp;<%=Fk_GBook_Time%></td>
        </tr>
		<tr>
			<td height="30" align="right">是否显示：</td>
            <td>&nbsp;<input type="radio" name="Fk_GBook_Show" class="input" id="Fk_GBook_Show" value="0"<%=FKFun.BeCheck(Fk_GBook_Show,0)%> />不显示
				<input type="radio" name="Fk_GBook_Show" class="input" id="Fk_GBook_Show" value="1"<%=FKFun.BeCheck(Fk_GBook_Show,1)%> />显示<span class="help" title="<p>配置该<%=ModelName%>是否在前台显示。</p>"></span>
			</td>
		</tr>
        <tr>
            <td height="30" align="right">回复：</td>
            <td>&nbsp;<textarea name="Fk_GBook_Re" class="textarea" cols="60" rows="5" id="Fk_GBook_Re"><%=Fk_GBook_Re%></textarea></td>
        </tr>
	</table>
</div>
<div id="bottom">
	<input type="hidden" name="Id" value="<%=Id%>" />
	<input type="submit" class="button" name="Enter" id="Enter" value="修 改" />
	<input type="button" onclick="dialogClose();" class="button" name="button" id="button" value="关 闭" />
</div>
</form>
<%
End Sub

'==============================
'函 数 名：GBookReDo
'作    用：执行回复留言
'==============================
Sub GBookReDo()
	Fk_GBook_Re=FKFun.HTMLEncode(Trim(Request.Form("Fk_GBook_Re")))
	Fk_GBook_Show=Trim(Request.Form("Fk_GBook_Show"))
	Id=Trim(Request.Form("Id"))
	Call FKFun.JsonString(Fk_GBook_Re,1,500,0,"请输入回复！","回复不能大于500个字符！")
	Call FKFun.JsonNum(Fk_GBook_Show,"请选择是否显示！")
	Call FKFun.JsonNum(Id,"系统参数错误，请刷新页面！")
	Sqlstr="Select Fk_GBook_Id,Fk_GBook_Show,Fk_GBook_Re,Fk_GBook_ReAdmin,Fk_GBook_ReIp,Fk_GBook_ReTime From [Fk_GBook] Where Fk_GBook_Module="&ModuleId&" And Fk_GBook_Id=" & Id
	Rs.Open Sqlstr,Conn,1,3
	If Not Rs.Eof Then
		Application.Lock()
		Rs("Fk_GBook_Show")=Fk_GBook_Show
		Rs("Fk_GBook_Re")=Fk_GBook_Re
		Rs("Fk_GBook_ReAdmin")=UId
		Rs("Fk_GBook_ReIp")=Request.ServerVariables("REMOTE_ADDR")
		Rs("Fk_GBook_ReTime")=Now()
		Rs.Update()
		If Fk_Site_Html=2 And (ModuleGBookReply=0 Or ModuleGBookReply=1) Then
			Sqlstr="Update [Fk_Module] Set Fk_Module_ToHtml=1 Where Fk_Module_Id=" & ModuleId
			Conn.Execute(Sqlstr)
		End If
		Application.UnLock()
		Call FKFun.JsonSuccess()
	Else
		Rs.Close
		Call FKFun.JsonError("要处理的"&ModelName&"不存在！")
	End If
	Rs.Close
End Sub

'==============================
'函 数 名：GBookDelDo
'作    用：执行删除留言
'==============================
Sub GBookDelDo()
	Id=Trim(Request.QueryString("Id"))
	Call FKFun.ShowNum(Id,"系统参数错误，请刷新页面！")
	Sqlstr="Select Fk_GBook_Id From [Fk_GBook] Where Fk_GBook_Module="&ModuleId&" And Fk_GBook_Id=" & Id
	Rs.Open Sqlstr,Conn,1,3
	If Not Rs.Eof Then
		Application.Lock()
		Rs.Delete()
		Application.UnLock()
		Response.Write("ok")
	Else
		Response.Write("要删除的"&ModelName&"不存在！")
	End If
	Rs.Close
End Sub

'==============================
'函 数 名：GBookBatchDelDo
'作    用：执行批量删除留言
'==============================
Sub GBookBatchDelDo()
	Id=Replace(Trim(Request.Form("ListId"))," ","")
	If Id="" Then
		Call FKFun.JsonError("请选择要删除的内容！")
	End If

	Sqlstr="Delete From [Fk_GBook] Where Fk_GBook_Module="&ModuleId&" And Fk_GBook_Id In ("&Id&")"
	Application.Lock()
	Conn.Execute(Sqlstr)
	Application.UnLock()
	Call FKFun.JsonSuccess()
End Sub

Call FKFun.PageEnd()
%>